
 this.main=function(){
	var eidtform=null;
	var eidtwindow=null;
	var destroyObjs=[];
		var myobject=this;

	var sm = new Ext.grid.CheckboxSelectionModel({
				singleSelect : false
			});
	var cm=getdictablecolumn(sm);
	var dataRecord = Ext.data.Record.create([
			{name : 'tableid',	type : 'int'},
			{name : 'tablecnname',	type : 'string'},
			{name : 'tablename',	type : 'string'},
			{name : 'tabletype',	type : 'string'},
			{name : 'cachetag',	type : 'string'},
			{name : 'keycolumn',	type : 'string'},
			{name : 'codecolumn',	type : 'string'},
			{name : 'namecolumn',	type : 'string'},
			{name : 'supercolumn',	type : 'string'},
			{name : 'levelnocolumn',	type : 'string'},
			{name : 'statuscolumn',	type : 'string'},
			{name : 'predefine',	type : 'string'},
			{name : 'remark',	type : 'string'},
			{name : 'createuser',	type : 'string'},
			{name : 'createtime',	type : 'string'},
			{name : 'tablekind',	type : 'int'},
			{name : 'cntablekind',	type : 'string'}
			
			]);
	var store = new Ext.data.Store({
			 autoLoad : {
					params : {
						start : 0,
						limit : 30
					}
				},
				proxy : new Ext.data.HttpProxy({
						url : basepath+'../sysControl/system/SysDicTableController/query.do'
						}),

				reader : new Ext.data.JsonReader({
							totalProperty : 'results',
							root : "items",
							id : 'logid'
						}, dataRecord)
			});
	var comboStore=new Ext.data.Store({
		baseParams:{tablename:'sys_dicenumitem',groupcode:'TABLE_KIND'}, 
		 autoLoad : {tablename:'sys_dicenumitem',groupcode:'TABLE_KIND'},
			proxy : new Ext.data.HttpProxy({
					url :basepath+'../sysControl/system/SysDicTableController/getTableKind.do'

					}),

			reader : new Ext.data.JsonReader({
						totalProperty : 'results'
						}, 
						Ext.data.Record.create([
						               			{name : 'ItemID',	type : 'int'},
						            			{name : 'ElementCode',	type : 'string'},
						            			{name : 'Code',	type : 'string'},
						            			{name : 'Name',	type : 'string'}
						            			])),
		 listeners:{
				'load':function()
				{
					var retype = comboStore.recordType;
	                var p = new retype({
	                	ItemID:'',
	                	Name:'全部'
	                });
					this.insert(0,p);
				}
		 }
		});
var pagingBar = new Ext.PagingToolbar({// 分页工具栏
		store : store,
		pageSize : 30,// 每页显示的条数。用于系统自动计算它的start值
		displayInfo : true,
		displayMsg : '数据从第{0}条 - 第{1} 条 共 {2}条数据',
		emptyMsg : "没有记录"

	});
	
	function openwindow(title,url,isUpdate){
	if(isUpdate){
	 		var record = grid.getSelectionModel().getSelections();
				if (record.length <= 0) {
						Ext.MessageBox.alert('提示', '需要修改的记录');
						return;
					} else if (record.length > 1) {
						Ext.MessageBox.alert('提示', '最多只能选择一行');
						return;				
					}else if (record[0].data.predefine==1) {
						Ext.MessageBox.alert('提示', '系统预设不可编辑！');
						return;				
					}
	 	}
	 if(eidtwindow!=null){
	 	eidtwindow.setTitle(title);
	 	eidtwindow.actionUrl=url;
		eidtwindow.show();
		if(isUpdate)
			eidtform.getForm().setValues(record[0].data);
		else{
			eidtform.getForm().reset();
		var combo=Ext.getCmp('dicTableKind_'+myobject.menuid);
			combo.setValue(tableenum_s.getValue());
		}
		return;
		}
			  loadForm( basepath+"dic/js/dictableform.js",function(form){
			  		eidtform=form;
			  		destroyObjs[0]=form;
			  		eidtwindow = new Ext.Window({
							title : title,
							width : 382,
							closeAction : 'hide',
							plain : true,
							actionUrl:url,
							labelAlign : "right",
							buttonAlign : "center",
							resizable:false,
							modal:true,
							padding:"2px 2px",
							items : [eidtform],
							buttons : [ {text:"保存",
										   handler : function(){
										   		submitFormPanel(eidtform, eidtwindow.actionUrl, function(form,action){
										   		
										   			Ext.Msg.alert("提示",action.result.info);
										   				store.reload();
										   		})
										   
										   }
										},
										{text:"关闭",
										   handler : function() {
												eidtwindow.hide();	
										 	}
										}
									  ]
				
					});
			  		destroyObjs[1]=eidtwindow;
				if(isUpdate)
					eidtform.getForm().setValues(record[0].data);
				else{
					eidtform.getForm().reset();
					  	var combo=Ext.getCmp('dicTableKind_'+myobject.menuid);
					  	function setTableKindValue(){
					  	combo.setValue(tableenum_s.getValue());
					  	combo.getStore().un('load',setTableKindValue);
					  	}
					  	combo.getStore().on('load',setTableKindValue);
			  			    
				}
				eidtwindow.show();	  	 
			

			  },myobject);
	
	}
	
	var grid = new Ext.ux.grid.LockingGridPanel({
		cm : cm,
		sm : sm,
		width:frame_center.getInnerWidth()-4,
		height:frame_center.getInnerHeight()-28,
		renderTo:'divLlist'+this.menuid,
		store : store,
		tbar : [{
			text : '添加',
			iconCls : 'table_add',
			handler : function() {
			 openwindow("添加数据表", basepath+"../sysControl/system/SysDicTableController/add.do",false);
			}
		},{
			text : '修改',
			iconCls : 'table_edit',
			handler : function() {
			openwindow("修改数据表", basepath+"../sysControl/system/SysDicTableController/update.do",true);
			}
		},{
			text : '列维护',
			iconCls : 'table_goto',
			handler : function() {
				var record = grid.getSelectionModel().getSelections();
				if (record.length <= 0) {
						Ext.MessageBox.alert('提示', '需要修改的记录');
						return;
					} else if (record.length > 1) {
						Ext.MessageBox.alert('提示', '最多只能选择一行');
						return;				
					}
				var mytablename=record[0].data.tablename;
				var taburl = 'dic/jsp/columncfg.jsp?menuid=tabcolumn_'+mytablename+'&tablename='+mytablename;
				addFrameCenterTab("tabcolumn_"+mytablename,taburl,mytablename+'表 列维护');
			}
		},{
			text : '表单维护',
			iconCls : 'table_goto',
			handler : function() {
				var record = grid.getSelectionModel().getSelections();
				if (record.length <= 0) {
						Ext.MessageBox.alert('提示', '需要修改的记录');
						return;
					} else if (record.length > 1) {
						Ext.MessageBox.alert('提示', '最多只能选择一行');
						return;				
					}
				var mytablename=record[0].data.tablename;
				var taburl = 'dic/jsp/formcfg.jsp?menuid=columnformcfg_'+mytablename+'&tablename='+mytablename;
				addFrameCenterTab("tabcolumn_"+mytablename,taburl,mytablename+'表 表单维护');

			}
		},'->',{xtype:'colModelJsButton',url:'sys/dic/js/dictablecolumn.js',menuid:this.menuid},
				{xtype:'outputExcelButton',title:'表设置'},{xtype:'closePage'}
		],
		bbar : pagingBar
	});
	var tablename = new Ext.form.TextField({});
	var tablecnname = new Ext.form.TextField({});
	var tableenum_s=new Ext.form.ComboBox({
		maxLength : 12,
		triggerAction : 'all',
		mode : 'remote',
		valueField : 'ItemID',
		displayField : 'Name',
		store:comboStore
	})

			var tbar2 = new Ext.Toolbar({
				renderTo : grid.tbar,
				items : ['表名',tablecnname,'表编码',tablename,'表类型',tableenum_s,
						{ text:'查询',iconCls:'table_find',tooltip : '查询',
					  	handler : function() {
					  			addStoreBaseParams(tablename,'tablename',store);
					  			addStoreBaseParams(tablecnname,'tablecnname',store);
					  			addStoreBaseParams(tableenum_s,'tablekind',store);
								store.load({params:{start:0,limit:30}});
						}
				}]
			});
	destroyObjs[2]=tbar2;
destroyResize(grid,destroyObjs);
}
